package com.macro.mall.tiny.modules.pms.controller;


import com.macro.mall.tiny.common.api.CommonResult;
import com.macro.mall.tiny.modules.pms.model.PmsSystemManage;
import com.macro.mall.tiny.modules.pms.service.PmsSystemManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 产品系统管理 前端控制器
 * </p>
 *
 * @author tyrone
 * @since 2024-11-23
 */
@RestController
@RequestMapping("/pms/pmsSystemManage")
@Api(tags = "PmsSystemManageController")
@Tag(name = "PmsSystemManageController", description = "产品系统管理")
public class PmsSystemManageController {

    @Autowired
    private PmsSystemManageService pmsSystemManageService;

    @ApiOperation("根据id获取系统管理")
    @GetMapping("/getSystemManage")
    public CommonResult<PmsSystemManage> getSystemManage(@RequestParam Long id) {
        PmsSystemManage pmsSystemManage = pmsSystemManageService.getById(id);
        return CommonResult.success(pmsSystemManage);
    }

    @ApiOperation("获取所有系统管理")
    @GetMapping("/getAllSystemManage")
    public CommonResult<List<PmsSystemManage>> getAllSystemManage() {
        List<PmsSystemManage> pmsSystemManageList = pmsSystemManageService.list();
        return CommonResult.success(pmsSystemManageList);
    }

    @ApiOperation("根据id更新系统管理")
    @PostMapping("/updateSystemManage")
    public CommonResult<Void> updateSystemManage(@RequestBody PmsSystemManage pmsSystemManage) {
        boolean success = pmsSystemManageService.updateById(pmsSystemManage);
        if (success) {
            return CommonResult.success(null);
        } else {
            return CommonResult.failed();
        }
    }



}

